home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------------
-
- key.c
-
- This reusable module handles miscellaneous tasks involving the keyboard.
-
- Copyright © 1994-1995, Northwestern University.
-
- ----------------------------------------------------------------------------*/
-
- #include "def.h"
- #include "key.h"
-
-
-
- /*----------------------------------------------------------------------------
- IsKeypadKey
-
- Check for numeric keypad key.
-
- Entry: theChar = ASCII code of key.
- theKey = keyboard code of key.
-
- Exit: function result = true if numeric keypad key.
- *theKeypadKey = which keypad key, if function result is true.
- ----------------------------------------------------------------------------*/
-
- Boolean IsKeypadKey (unsigned char theChar, unsigned char theKey,
- TKeypadKey *theKeypadKey)
- {
- if (theChar == 0x1B && theKey == 0x47) {
- *theKeypadKey = kKeypadClearKey;
- return true;
- }
- if (theChar == '=' && (theKey == 0x48 || theKey == 0x51)) {
- *theKeypadKey = kKeypadEqualKey;
- return true;
- }
- if (theChar == '/' && (theKey == 0x4d || theKey == 0x4b)) {
- *theKeypadKey = kKeypadSlashKey;
- return true;
- }
- if (theChar == '*' && (theKey == 0x42 || theKey == 0x43)) {
- *theKeypadKey = kKeypadStarKey;
- return true;
- }
- if (theChar == '-' && theKey == 0x4e) {
- *theKeypadKey = kKeypadMinusKey;
- return true;
- }
- if (theChar == '+' && (theKey == 0x46 || theKey == 0x45)) {
- *theKeypadKey = kKeypadPlusKey;
- return true;
- }
- if (theChar == enterKey && theKey == 0x4c) {
- *theKeypadKey = kKeypadEnterKey;
- return true;
- }
- if ((theChar == '.' || theChar == ',') && theKey == 0x41) {
- *theKeypadKey = kKeypadPeriodKey;
- return true;
- }
- if (theChar == '0' && theKey == 0x52) {
- *theKeypadKey = kKeypad0Key;
- return true;
- }
- if (theChar == '1' && theKey == 0x53) {
- *theKeypadKey = kKeypad1Key;
- return true;
- }
- if (theChar == '2' && theKey == 0x54) {
- *theKeypadKey = kKeypad2Key;
- return true;
- }
- if (theChar == '3' && theKey == 0x55) {
- *theKeypadKey = kKeypad3Key;
- return true;
- }
- if (theChar == '4' && theKey == 0x56) {
- *theKeypadKey = kKeypad4Key;
- return true;
- }
- if (theChar == '5' && theKey == 0x57) {
- *theKeypadKey = kKeypad5Key;
- return true;
- }
- if (theChar == '6' && theKey == 0x58) {
- *theKeypadKey = kKeypad6Key;
- return true;
- }
- if (theChar == '7' && theKey == 0x59) {
- *theKeypadKey = kKeypad7Key;
- return true;
- }
- if (theChar == '8' && theKey == 0x5b) {
- *theKeypadKey = kKeypad8Key;
- return true;
- }
- if (theChar == '9' && theKey == 0x5c) {
- *theKeypadKey = kKeypad9Key;
- return true;
- }
- return false;
- }